package com.study.designPattern.observer.example;

import java.util.ArrayList;
import java.util.List;

/**
 * 创建人： HBZ，时间： 2017/8/22 11:23.
 * 说明：具体主题，这里是客户
 */
public class Customer implements Subject {
    private String customerState;//客户状态

    private List<JobStation> observers = new ArrayList<JobStation>();

    /// <summary>
    /// 增加观察者
    /// </summary>
    /// <param name="observer"></param>
    public void Attach(JobStation observer) {
        this.observers.add(observer);
    }

    /// <summary>
    /// 移除观察者
    /// </summary>
    /// <param name="observer"></param>
    public void Detach(JobStation observer) {
        this.observers.remove(observer);
    }


    public void Notify() {

        for (JobStation o : observers) {
            o.Update(this);
        }
    }

    public String getCustomerState() {
        return customerState;
    }

    public void setCustomerState(String customerState) {
        this.customerState = customerState;
    }
}
